package JASYPT;

import org.jasypt.util.password.PasswordEncryptor;
import org.jasypt.util.password.BasicPasswordEncryptor;

public class PasswordEncryptorDemo {
	
	public static void main(String[] args) {
		//
		// Creates an instance of BasicPasswordEncryptor.
		//
		PasswordEncryptor encryptor = new BasicPasswordEncryptor();

		//
		// Encrypted version of user password.
		//
		String encrypted = encryptor.encryptPassword("secret");
		System.out.println("encrypted = " + encrypted);

		//
		// Compare user's plain text password with the encrypted one to check
		// if they are match.
		//
		if (encryptor.checkPassword("secret", encrypted)) {
			System.out.println("Welcome to Jasypt");
		} else {
			System.out.println("Invalid secret word, access denied!");
		}
	}
}